<?php

namespace app\api\model\courses;

use app\common\model\CoursesCategory as CategoryModel;

/**
 * 商品分类模型
 * Class Category
 * @package app\common\model
 */
class Category extends CategoryModel
{
    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = [
        'wxapp_id',
        'update_time'
    ];

    /**
     * 获取列表数据
     * @param int $campus_id
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getList( $campus_id = 0)
    {
        $campus_id > 0 && $this->where('campus_id', '=', (int)$campus_id);
        // 查询列表数据
        return $this->with(['campus','category','category.image'])
            ->order(['create_time' => 'desc'])
            ->paginate(15, false, [
                'query' => \request()->request()
            ]);
    }


    public function detail($courses_category_id){
        return $this->find($courses_category_id);
    }

}
